Changes On Branch improvements-to-main-menu

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

Changes In Branch improvements-to-main-menu Excluding Merge-Ins

This is equivalent to a diff from ec284f5af0 to 612332f50d

2019-02-16
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
01:28
cleanup: tab to spaces check-in: 27ce672990 user: tion tags: improvements-to-main-menu
2019-02-15
18:23
Add status bar check-in: 8946855f9a user: tion tags: improvements-to-main-menu
06:09
Fix minor typo with author check-in: ec284f5af0 user: tion tags: trunk
06:02
Remove outdated preview video from version tracking check-in: 6726144a89 user: tion

Changes to src/CoordinateData.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
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










-
-
+
+




-
-
+
+





+
+
+
+
+
+
+
+
+
+
+
+








-
-
+
+









-
-
+
+







//==================================================================
#include "CoordinateData.h"
#include "HelperFunctions.h"
//==================================================================
///////////////////////////
// CLASS: coordinateData //
///////////////////////////
//==================================================================
coordinateData::coordinateData()
{
   initCoordinates();
   initGlyphs();
   createCoordinates();
   createGlyphs();
}
//------------------------------------------------------------------
coordinateData::coordinateData (const QString &_code, bool isCoordinate)
{
	initCoordinates();
	initGlyphs();
   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)
{
	initCoordinates();
	initGlyphs();
   createCoordinates();
   createGlyphs();

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

   portal = other.portal;
   coordinates = other.coordinates;
   glyph_code = other.glyph_code;
   error_info = other.error_info;
}
//------------------------------------------------------------------
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
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







-
-
-
-
-
-
+
+
+
+
+
+
+
-










-
+




-
+




-
+




-
+




-
-










-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+




-
+




-
-
+
+












-
-
+
+




-
-
+
+











-
+
+




-
+




-
+








   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;
   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());
   return (glyph_code.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinate() const
{
	return (coordinates.toUpper());
   return (coordinates.toUpper());
}
//------------------------------------------------------------------
QString coordinateData::getCoordinates() const
{
	return (getCoordinate());
   return (getCoordinate());
}
//------------------------------------------------------------------
QStringList coordinateData::getErrorInfo() const
{
	return (error_info);
   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();
   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");
	}
   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);
   return (result);
}
//------------------------------------------------------------------
int coordinateData::getPortal() const
{
	return (portal);
   return (portal);
}
//------------------------------------------------------------------
void coordinateData::setCoordinate (const QString &_code)
{
	if ( _code != coordinates )
		coordinates = _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;
   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;
   if ( error_data.size() > 0 && error_data.at (0) != ':' )
      error_info += error_data;
}
//------------------------------------------------------------------
void coordinateData::reset()
{
   clearCoordinates();
   clearGlyphCode();
   clearErrorInfo();
}
//------------------------------------------------------------------
void coordinateData::clearCoordinates()
{
	coordinates.clear();
   coordinates.clear();
   portal = 1;
}
//------------------------------------------------------------------
void coordinateData::clearGlyphCode()
{
	glyph_code.clear();
   glyph_code.clear();
}
//------------------------------------------------------------------
void coordinateData::clearErrorInfo()
{
	error_info.clear();
   error_info.clear();
}
//------------------------------------------------------------------
void coordinateData::convertFromGlyph()
{
   // Verify glyph code is valid hexadecimal and is valid
   // glyph code sequence.
   clearErrorInfo();
212
213
214
215
216
217
218

219
220
221
222
223
224
225
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239







+







          => 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();

294
295
296
297
298
299
300
301

302
303
304
305

306
307
308
309
310
311
312
308
309
310
311
312
313
314

315
316
317
318

319
320
321
322
323
324
325
326







-
+



-
+







      temp_str = coordinate_x + ":" + coordinate_y + ":" + coordinate_z +
                 ":" +
                 coordinate_star;
      coordinates = (QString(temp_str).toUpper());
   }
   else
   {
      // Add invalid code segments to element info
      // 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)));
            addToErrorInfo (QString(temp_info.at (i)));
      }
      else
         addToErrorInfo (glyph_code);
   }
}
//------------------------------------------------------------------
void coordinateData::convertToGlyph()
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
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







-
+

-
+


-
+

-
-
-
+
+
+








-
+











-
+






-
+






-
+

-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+


-
+




-
+

-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+


-
+




-
+






-
+







   }
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////
//------------------------------------------------------------------
void coordinateData::initGlyphs()
void coordinateData::createGlyphs()
{
	glyph_code = QString();
   glyph_code = QString();
}
//------------------------------------------------------------------
void coordinateData::initCoordinates()
void coordinateData::createCoordinates()
{
	coordinates = QString();
	portal = int(1);
	error_info = QStringList();
   coordinates = QString();
   portal = int(1);
   error_info = QStringList();
}
//------------------------------------------------------------------
//////////////////////
// FRIEND FUNCTIONS //
//////////////////////
//------------------------------------------------------------------
QTextStream &operator >> (QTextStream &readInputInto, coordinateData &target)
{
   // Read into ins:
   // 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();
   outs << the_data.toString();

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

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

	outs << "[DEBUG][coordinateData]";
   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.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.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();
	   }
      if ( the_data.error_info.isEmpty() == false )
      {
         outs << "\ninvalid segments: ";
         outs.noquote() << the_data.showErrorInfo();
      }
   }

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

	outs << "[DEBUG][coordinateData]";
   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.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.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();
	   }
      if ( the_data.error_info.isEmpty() == false )
      {
         outs << "\ninvalid segments: ";
         outs.noquote() << the_data.showErrorInfo();
      }
   }

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

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

   return (outs);
}
//------------------------------------------------------------------
//////////////////////////
// COMPARISON OPERATORS //
//////////////////////////
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
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







-
+

-
-
+
+






-
+

-
-
+
+







   }

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

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

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

	if ( !(a == b) )
		result = true;
   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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17







+

+







//==================================================================
#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
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
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







-
+
-
-
-
+



-
+



+



-
+
+
+
+








-
+
+
+
+
+










-
+
+
+
+
+













+
+
+
-
+
+







*/
class coordinateData : public QObject
{
   public:
      //////////////////
      // CONSTRUCTORS //
      //////////////////
      /** \details Default constructor. Initializes all variables to
      /** Default constructor. */
       *  null/empty values.
      */
      coordinateData();
      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 work to obtain).
       *  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.
      */
      coordinateData(const QString &_code, bool isCoordinate = true);
      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) **/
      /** \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) */
      /** \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. */
       *  \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.
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
215
216
217
218
219
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
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







+




















-
-
-
+
+
+












+






+
+
+
+
+
+
+
+






-
+



-
+







       *      <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, const coordinateData &the_data);
      /** \overload operator<<(QTextStream &outs, coordinateData &the_data)
       * 
       *  \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;
       *	      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 initGlyphs();
      void createGlyphs();
      /** \details Sets coordinate to empty value, and portal number
       *  to default value of one (1).
      */
      void initCoordinates();
      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
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







-
-






-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+










-
-













-
-
-
-
-
-
+
+
+
+
+
+







//==================================================================
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.";
	      }
         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.";
		   }
		}
            if ( guess -> getGlyphCode().isEmpty() == false )
               outs << *guess;
            else
               outs << "No glyph code provided.";
         }
      }
   }
}
//------------------------------------------------------------------
inline void setApplicationSettings()
{
   QCoreApplication::setOrganizationName ("tion");
   QCoreApplication::setApplicationName ("nmspd");
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
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







-
+







-
+

















-
+




-
+

-
+




-
+





-
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+

-








      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);
            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), bool(false), outs, verb);
            to_coords (args.at(i), false, outs, verb);
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
            outs << "Try again without any options.";
         }
         else
         {
            // 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);
                  to_coords (args.at(i), false, outs, verb);
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), bool(true), outs, verb);
                  to_glyphs (args.at(i), true, outs, verb);
               }
               else { }
               else { /* Assume invalid input */ }
            }
         }
      }

      // Exit properly rather than keep waiting for input.
      // Exit properly rather than waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);
	  	setApplicationSettings();
      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\':" <<
      qDebug() << "Available options for \'-style\':" <<
                  QStyleFactory::keys().join(", ");
      }

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

   return (0);
}

Changes to src/CoordinateMainWindow.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
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










-
+
+

-
-
+
+




-
+
+

-
-
+
+






-
+




-
+




-
+




-
+




-
+







//==================================================================
#include <QRegularExpressionMatch>

#include "PortalAddressWindow.h"
#include "CoordinateMainWindow.h"
//==================================================================
///////////////////
// CLASS: Window //
///////////////////
//==================================================================
Window::Window (QWidget *parent) : QWidget (parent)
Window::Window (QWidget *parent)
   : QWidget (parent)
{
   initCoordinates();
   initGlyphs();
   createCoordinates();
   createGlyphs();

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

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

	createLayout();
   createLayout();
}
//------------------------------------------------------------------
QString Window::getGlyphCode()
{
	return (glyph_sequence -> text());
   return (glyph_sequence -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinate()
{
	return (coordinates_input -> text());
   return (coordinates_input -> text());
}
//------------------------------------------------------------------
QString Window::getCoordinates()
{
	return (getCoordinate());
   return (getCoordinate());
}
//------------------------------------------------------------------
int Window::getPortal()
{
	return (portal_number -> value());
   return (portal_number -> value());
}
//------------------------------------------------------------------
void Window::createLayout()
{
   // Set minimum size of window
   setMinimumSize(415, 50);
   
200
201
202
203
204
205
206
207
208
209



210
211

212
213
214
215
216
217
218
202
203
204
205
206
207
208



209
210
211
212

213
214
215
216
217
218
219
220







-
-
-
+
+
+

-
+







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
   if ( the_errors.isEmpty() == true || QString(the_errors.join("")) == ":::" )
      text += QString (tr ("No code provided."));
   else
   {
	   text += QString(tr ("Problematic section: "));
      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") );
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
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







-
+









-
+







//------------------------------------------------------------------
void Window::preset_hova()
{
   setCoordinatePreset ("0467:0081:0D71:00AD", 1);
   GUI_convertToGlyph();
}
//------------------------------------------------------------------
void Window::initGlyphs()
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::initCoordinates()
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 
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
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







-
-
+
+




-
+
-
-
-
-
-






-
+


-
+


-
+

-
+

-
-
-
-
+
+
+
+




-
-
-
+
+









-
+


-
-
+
+


-
+

-
+

-
-
-
-
+
+
+
+




-
-
-
+
+






-
+


{
   clearCoordinates();
   clearGlyphCode();
}
//------------------------------------------------------------------
void Window::clearCoordinates()
{
	coordinates_input -> clear();
	portal_number -> setValue (1);
   coordinates_input -> clear();
   portal_number -> setValue (1);
}
//------------------------------------------------------------------
void Window::clearGlyphCode()
{
	glyph_sequence -> clear();
   glyph_sequence -> clear();
}
//------------------------------------------------------------------
void Window::clearMessages()
{
	//blackbox -> clearErrorInfo();
}
//------------------------------------------------------------------
void Window::GUI_convertFromGlyph()
{
   if ( glyph_sequence -> text().size() == 12 )
   {
   	coordinateData *blackbox = new coordinateData;
      coordinateData blackbox = coordinateData();

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

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

      if ( blackbox -> getCoordinates().size() == 19 )
      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());
         // 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() << "emitting haveErrors";
      	qDebug() << *blackbox;
         emit haveErrors (blackbox -> getErrorInfo());
         qDebug() << blackbox;
         emit haveErrors (blackbox.getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::GUI_convertToGlyph()
{
   if ( coordinates_input -> text().isEmpty() == false
     && coordinates_input -> text() != ":::" )
   {
   	coordinateData *blackbox = new coordinateData;
      coordinateData blackbox = coordinateData();

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

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

      if ( blackbox -> getGlyphCode().size() == 12 )
      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());
         // 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() << "emitting haveErrors";
      	qDebug() << *blackbox;
         emit haveErrors (blackbox -> getErrorInfo());
         qDebug() << blackbox;
         emit haveErrors (blackbox.getErrorInfo());
      }
   }
}
//------------------------------------------------------------------
void Window::syncGlyphCode()
{
	emit glyphChange();
   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
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







-
+










-
+







-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+









-
-
-
-
+
+
+
+



-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+


-
-
-
-
-
+
+
+
+
+




-
+



-
+
-



-
+







 * 
*/
class Window : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

	public:
   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);
      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();
      /** \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.
		*/
      /** 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 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();
      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
   	*/
      /** 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
       *  \see coordinateData::convertFromGlyph
      */
      void GUI_convertFromGlyph();
      /** Emits the signal glyphChange. */
	  	void syncGlyphCode();
      void syncGlyphCode();
      //void about();
      /** Show errors in a QMessageBox about the supplied code
       *  preventing conversion.
      */
      void showMessages (QStringList);
      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. */
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
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







-
-
+
-
-
-
-
-
+
+
+

-
-
-
-
-
+
+



-
+

-
+
-
-
-
+
+
-
-







      */
      /** 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.
   private:
      /*
         PRIVATE FUNCTIONS
      */
      void clearMessages();

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

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

      // 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
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);
      errors.append (__code);
   }

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

Changes to src/HelperFunctions.h.

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
1
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
 *  \see coordinateData
*/
//------------------------------------------------------------------
#ifndef __HELPER_FUNCTIONS_H__
#define __HELPER_FUNCTIONS_H__
//------------------------------------------------------------------
#include <QtCore>
//------------------------------------------------------------------

Changes to src/MainWindow.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
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













-
+
+
+

+

-
+
-
-
-
+







+








+







//------------------------------------------------------------------
#include <QtWidgets>

#include "MainWindow.h"
//------------------------------------------------------------------
///////////////////////
// CLASS: MainWindow //
///////////////////////
//------------------------------------------------------------------
/////////////////
// CONSTRUCTOR //
/////////////////
//------------------------------------------------------------------
MainWindow::MainWindow()
MainWindow::MainWindow (QWidget *parent)
   : QMainWindow (parent),
   conversion_screen (new Window(this))
{
   setCentralWidget (conversion_screen);
   setWindowTitle ("nmspd");
   

   conversion_screen = new Window;
   setCentralWidget (conversion_screen);

   // 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 //
//////////////////
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
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







+










+



-
+


+



-
+


+










-









-
+



+
+















+
+
+
+
+








-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


   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"));
   //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.
   //
   // 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);
}
//------------------------------------------------------------------
void MainWindow::createMenus()
{
   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>"));
   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
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




-
-
-
-




-
-







-
-
+
+











-
+









-
+


-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+


-
+




-
+
+
+







//==================================================================
#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;
 *       MainWindow example;
 *	      example.show();
 * 
*/
class MainWindow : public QMainWindow
{
   Q_OBJECT

   public:
      /////////////////
      // CONSTRUCTOR //
      /////////////////
      /** Default constructor. */
      MainWindow();
      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. */
      /** 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();
      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. */
      /** 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();
      void createToolBar();
      /** Initializes the status bar. */
      void createStatusBar();

      // MenuBar items
      /** \var QMenu *fileMenu
       *
       *  \brief Menu item for 'File'.
      */
      QMenu *fileMenu;
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
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







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+










      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.
	  	*/
      /** \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.

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
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
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
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








-
+
+

-
-
+
+
+


-
+
+

-
+

+
-
+


-
+

+
+
+
+






+

+


-
+


-
-
-
-
-
-
-
-
-
-













-
+
-
















-
-
+
-
-
+


-
-




















-
+







-
+

-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
-







//==================================================================
#include "PortalAddressPickerWindow.h"
#include "HelperFunctions.h"
//==================================================================
/////////////////////////
// CLASS: PortalDialer //
/////////////////////////
//------------------------------------------------------------------
PortalDialer::PortalDialer (QWidget *parent) : QWidget (parent)
PortalDialer::PortalDialer (QWidget *parent)
   : QWidget (parent)
{
   initGlyphs();
   initLayout();
   createGlyphs();
   createActions();
   createLayout();
}
//------------------------------------------------------------------
PortalDialer::PortalDialer (const QString &_code)
PortalDialer::PortalDialer (const QString &_code, QWidget *parent)
   : QWidget (parent)
{
   initGlyphs();
   createGlyphs();
   setGlyphs(_code);
   createActions();
   initLayout();
   createLayout();
}
//------------------------------------------------------------------
void PortalDialer::initGlyphs()
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 (false);
      glyph_input[i] -> setFlat (true);
      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;
         QStack<QChar> temp = QStack<QChar>();
         temp.clear();
         const QRegularExpression validHex ("[0-9A-F]");
         QRegularExpressionMatch isValidHex;

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

               if ( isValidHex.hasMatch() == true )
               {
                  //code -> push(_code.at(i).toUpper());
                  temp.push(_code.at(i).toUpper());
                  temp.push (_code.at (i).toUpper());
                  //emit codeChange();
                  fileName = ":" + QString(_code.at(i)).toUpper() + ".jpg";
                  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 )
            emit codeReady();
      }
      else
         emit codeIncomplete();
   }
}
//------------------------------------------------------------------
QString PortalDialer::getCode()
{
   QString result = QString();

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

   return (result);
}
//------------------------------------------------------------------
void PortalDialer::getGlyph (const int index)
{
   if ( code -> size() < 12 )
   if ( code -> size() >= 0 && code -> size() < 12 )
   {
      int i = (code -> size());
      QChar result = convert_integer_to_hex(index).at(0);
      code -> push (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();
      glyph_code -> setText (getCode());
      emit codeChange();
      }
   }

   // Update status of code after (any) change
   if ( code -> size() == 12 )
      emit codeReady();
   else
   {
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
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







-







-
+

-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+














-
-
-
-
-
-
+
+
+
+
+
+







}
//------------------------------------------------------------------
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()
void PortalDialer::createActions()
{
   glyph_code = new QLineEdit;
   glyph_code -> setMaxLength (12);
   glyph_code -> setReadOnly (true);

   // 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   |
      +----------------+
      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);
234
235
236
237
238
239
240
241
242
















243
244
245

246
247
248
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







-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
+




   /*
     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
}
//------------------------------------------------------------------
///////////////////
// 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++)
   {
   	QObject::connect (glyph_input[i], &QPushButton::clicked, this, [=] { getGlyph (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
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;
 *       // Create an empty object
 *       PortalDialer example;
 * 
 * 		// Show a specific glyph code sequence
 * 		example.setGlyphs ("00234567890AB");
 * 		example.show();
 *       // Show a specific glyph code sequence
 *       example.setGlyphs ("00234567890AB");
 *       example.show();
 * 
*/
class PortalDialer : public QWidget
{
   Q_OBJECT
    
	public:
   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);
      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.
		*/
      /**
       *  \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();
   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. */
   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);
      void getGlyph(const int index);

	private:
		/** Initializes glyph_input to empty QPushButtons. */
      void initGlyphs();
   private:
      /*
         PRIVATE FUNCTIONS
      */
      /** Initializes glyph_input to empty QPushButtons. */
      void createGlyphs();
      /** Initializes the layout. */
      void initLayout();
      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;
     	//QPushButton *glyph_select[12];
      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
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


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
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)
//------------------------------------------------------------------
Glyphs::Glyphs (QWidget *parent)
   : QWidget (parent)
{
   initGlyphs();
   createGlyphs();
   setGlyphs (QString());
   createLayout();
}
//------------------------------------------------------------------
Glyphs::Glyphs (const QString &_code)
Glyphs::Glyphs (const QString &_code, QWidget *parent)
   : QWidget (parent)
{
   initGlyphs();
   createGlyphs();
   setGlyphs (_code);
   createLayout();
}
//------------------------------------------------------------------
void Glyphs::initGlyphs()
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 (false);
      glyph[i] -> setFlat (true);
   }
}
//------------------------------------------------------------------
void Glyphs::showGlyphs()
{
	setGlyphs (glyph_code);
   setGlyphs (glyph_code);
}
//------------------------------------------------------------------
void Glyphs::showGlyphs (const QString &_code)
{
	setGlyphs (_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 |
       +--------+--------+-----+---------+
   */
   QGroupBox *the_glyphs = new QGroupBox;
   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()));
}
//==================================================================
//------------------------------------------------------------------

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
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







-
-
+
+

-
-
-
+
+
+

-
+




















-
+
-
-
-







 *
 *  \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;
 *       // Create empty glyph sequence
 *       Glyphs example;
 * 
 * 		// Show sequence: 200d01345678
 * 		example.showGlyphs ("200d01345678");
 * 		example.show();
 *       // Show sequence: 200d01345678
 *       example.showGlyphs ("200d01345678");
 *       example.show();
 * 
 *  \see CoordinateData::glyph_code
 *  \see coordinateData::glyph_code
*/
class Glyphs : public QWidget
{
   // Macro to allow for custom slots and signals
   Q_OBJECT

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

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

      ////////////////////////////////
      // ACCESSING MEMBER FUNCTIONS //
      ////////////////////////////////
      /** Sets the glyph code sequence to be displayed.
       * 
       *  \param[in] _code A valid glyph code.
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
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







+
+
+
-
-
-
-
-
-
+
+
+
+
+
+







+
+
+
-
-
-
-
-
+
+
+
+
+
+
+




       *  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
   	*/
      /** \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 initGlyphs();
      /** 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__
//==================================================================