OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
akCore.h
Go to the documentation of this file.
1/*
2 * File: akCore.h
3 * Package: akCore
4 *
5 * Created on: February 06, 2020
6 * Author: Alexander Kuester
7 * Copyright (c) 2022 Alexander Kuester
8 * This file is part of the uiCore component.
9 * This file is subject to the terms and conditions defined in
10 * file 'LICENSE', which is part of this source code package.
11 */
12
13#pragma once
14
15 // AK header
17#include "OTCore/Flags.h"
18
19 // Qt header
20#include <QtCore/qstring.h> // QString
21#include <QtCore/qflags.h> // QFlags
22#include <QtCore/qcryptographichash.h>
23
24// C++ header
25#include <vector> // vector<T>
26#include <list> // list<T>
27#include <string>
28#include <sstream>
29
30// Forward declaration
31class QKeyEvent;
32
33namespace ak {
34
64
69
77
84
86 enum eventType : unsigned long long {
88 etActivated = 1 << 1,
89 etChanged = 1 << 2,
90 etCleared = 1 << 3,
91 etClicked = 1 << 4,
92 etClosing = 1 << 5,
93 etCollpased = 1 << 6,
95 etDestroyed = 1 << 8,
97 etExpanded = 1 << 10,
98 etFocused = 1 << 11,
99 etFocusLeft = 1 << 12,
100 etInvalidEntry = 1 << 13,
101 etIndexChanged = 1 << 14,
102 etItemChanged = 1 << 15,
104 etKeyPressed = 1 << 17,
105 etKeyReleased = 1 << 18,
108 etStateChanged = 1 << 21,
111 etTimeout = 1 << 24,
117 etDeleted = (unsigned long long ) (1) << 32
118 };
119
142
165
185
200
208
215
222
243
245 {
246 return static_cast<eventType>(static_cast<int>(a) | static_cast<int>(b));
247 }
248
250 {
251 return static_cast<colorAreaFlag>(static_cast<int>(a) | static_cast<int>(b));
252 }
253
254 inline bool flagIsSet(colorAreaFlag _flags, colorAreaFlag _testFlag) { return ((_flags & _testFlag) == _testFlag); }
255
256 // ############################################################################################################################################
257
258 // Converting
259
263 eventType _eventType
264 );
265
269 valueType _valueType
270 );
271
272 UICORE_API_EXPORT std::vector<int> toCharIndex(
273 const char * str
274 );
275
277 UICORE_API_EXPORT QCryptographicHash::Algorithm toQCryptographicHashAlgorithm(HashAlgorithm _algorhitm);
278
280 UICORE_API_EXPORT QString hashString(const QString & _str, HashAlgorithm _algorhitm);
281
283 template <class T> std::vector<T> toVector(const std::list<T> & _list) {
284 std::vector<T> ret;
285 ret.reserve(_list.size());
286 for (auto itm : _list) { ret.push_back(itm); }
287 return ret;
288 }
289
293 objectType _objectType
294 );
295
299 textAlignment _textAlignment
300 );
301
305 tabLocation _tabLocation
306 );
307
311 dockLocation _dockLocation
312 );
313
317 promptType _promptType
318 );
319
322 keyType _keyType
323 );
324
327 dateFormat _dateFormat
328 );
329
332 timeFormat _timeFormat
333 );
334
335 // Converting
336
337 // ############################################################################################################################################
338
339 // Parsing
340
345 QKeyEvent * _event
346 );
347
350 UICORE_API_EXPORT Qt::AlignmentFlag toQtAlignmentFlag(
351 textAlignment _textAlignment
352 );
353
355 UICORE_API_EXPORT dateFormat toDateFormat(const QString& _str);
356
358 UICORE_API_EXPORT timeFormat toTimeFormat(const QString& _str);
359
360 // Parsing
361
362 // ############################################################################################################################################
363
364 // Type checking
365
369 template <class T> T toNumber(const std::string& _string, bool & _failed) {
370 std::stringstream ss(_string);
371 T v;
372 ss >> v;
373 _failed = false;
374 if (ss.fail()) { _failed = true; }
375 std::string rest;
376 ss >> rest;
377 if (!rest.empty()) { _failed = true; }
378 return v;
379 }
380
384 template <class T> T toNumber(const QString& _string, bool & _failed) {
385 return toNumber<T>(_string.toStdString(), _failed);
386 }
387
391 template <class T> T toNumber(const char* _string, bool & _failed) {
392 return toNumber<T>(std::string(_string), _failed);
393 }
394
397 UICORE_API_EXPORT bool isDecimal(const char *str);
398
401 UICORE_API_EXPORT bool isDecimal(const std::string &str);
402
405 UICORE_API_EXPORT bool isDecimal(const QString &str);
406
409 UICORE_API_EXPORT bool isInteger(const char *str);
410
413 UICORE_API_EXPORT bool isInteger(const std::string &str);
414
417 UICORE_API_EXPORT bool isInteger(const QString &str);
418
421 UICORE_API_EXPORT bool isNumericOnly(const char *str);
422
425 UICORE_API_EXPORT bool isNumericOnly(const std::string &str);
426
429 UICORE_API_EXPORT bool isNumericOnly(const QString &str);
430
431} // namespace ak
#define UICORE_API_EXPORT
Definition globalDataTypes.h:20
Definition uiAPI.h:45
UICORE_API_EXPORT keyType toKeyType(QKeyEvent *_event)
Will return the key type of the provided QKeyEvent If the key is not included in the keyType type a k...
Definition akCore.cpp:344
timeFormat
Describes the time format.
Definition akCore.h:217
@ tfHHMM
Definition akCore.h:218
@ tfHHMMSSMMMM
Definition akCore.h:220
@ tfHHMMSS
Definition akCore.h:219
valueType
Definition akCore.h:223
@ vtLosslessFloat
Definition akCore.h:233
@ vtString
Definition akCore.h:238
@ vtUint64
Definition akCore.h:241
@ vtColor
Definition akCore.h:226
@ vtFloat
Definition akCore.h:229
@ vtDouble
Definition akCore.h:228
@ vtArray
Definition akCore.h:224
@ vtNull
Definition akCore.h:234
@ vtUint
Definition akCore.h:240
@ vtDate
Definition akCore.h:227
@ vtNumber
Definition akCore.h:235
@ vtTime
Definition akCore.h:239
@ vtInt64
Definition akCore.h:231
@ vtLosslessDouble
Definition akCore.h:232
@ vtInt
Definition akCore.h:230
@ vtBool
Definition akCore.h:225
@ vtSelection
Definition akCore.h:237
@ vtObject
Definition akCore.h:236
eventType operator|(eventType a, eventType b)
Definition akCore.h:244
UICORE_API_EXPORT std::vector< int > toCharIndex(const char *str)
Definition akCore.cpp:188
objectType
Describes the type of an object.
Definition akCore.h:167
@ otAction
Definition akCore.h:169
@ otMenu
Definition akCore.h:174
@ otTabToolbarGroup
Definition akCore.h:177
@ otTree
Definition akCore.h:182
@ otLabel
Definition akCore.h:171
@ otNone
Definition akCore.h:168
@ otLineEdit
Definition akCore.h:172
@ otMainWindow
Definition akCore.h:173
@ otToolButton
Definition akCore.h:181
@ otTimer
Definition akCore.h:180
@ otTreeItem
Definition akCore.h:183
@ otTabToolbarPage
Definition akCore.h:178
@ otTabToolbar
Definition akCore.h:176
@ otTabToolbarSubgroup
Definition akCore.h:179
@ otCheckBox
Definition akCore.h:170
@ otNiceLineEdit
Definition akCore.h:175
colorAreaFlag
Definition akCore.h:35
@ cafBorderColorWindow
Definition akCore.h:38
@ cafDefaultBorderControls
Definition akCore.h:45
@ cafForegroundColorWindow
Definition akCore.h:37
@ cafBackgroundColorView
Definition akCore.h:62
@ cafTabToolBarGroupSeperatorLine
Definition akCore.h:61
@ cafBackgroundColorAlternate
Definition akCore.h:47
@ cafBackgroundColorControls
Definition akCore.h:42
@ cafBackgroundColorFocus
Definition akCore.h:49
@ cafBorderColorHeader
Definition akCore.h:41
@ cafForegroundColorError
Definition akCore.h:48
@ cafDefaultBorderHeader
Definition akCore.h:56
@ cafBorderColorControls
Definition akCore.h:44
@ cafBackgroundColorSelected
Definition akCore.h:50
@ cafBackgroundColorDialogWindow
Definition akCore.h:57
@ cafDefaultBorderWindow
Definition akCore.h:46
@ cafForegroundColorFocus
Definition akCore.h:51
@ cafBackgroundColorButton
Definition akCore.h:59
@ cafBackgroundColorHeader
Definition akCore.h:39
@ cafBackgroundColorTransparent
Definition akCore.h:53
@ cafForegroundColorSelected
Definition akCore.h:52
@ cafImagesTree
Definition akCore.h:54
@ cafBackgroundColorWindow
Definition akCore.h:36
@ cafForegroundColorDialogWindow
Definition akCore.h:58
@ cafForegroundColorButton
Definition akCore.h:60
@ cafForegroundColorHeader
Definition akCore.h:40
@ cafForegroundColorControls
Definition akCore.h:43
@ cafImagesDock
Definition akCore.h:55
UICORE_API_EXPORT bool isNumericOnly(const char *str)
Returns true if the provided C-String consists only of numerical characters.
Definition akCore.cpp:123
UICORE_API_EXPORT QString toQString(eventType _eventType)
Create a string representation of the provided ak::core::eventType.
Definition akCore.cpp:19
UICORE_API_EXPORT bool isInteger(const char *str)
Returns true if the provided C-String is in a format ready to be converted to an integer.
Definition akCore.cpp:105
T toNumber(const std::string &_string, bool &_failed)
Will convert and return the number specified in the string.
Definition akCore.h:369
std::vector< T > toVector(const std::list< T > &_list)
Will return a vector containing all the information from the list.
Definition akCore.h:283
UICORE_API_EXPORT dateFormat toDateFormat(const QString &_str)
Will return the date format that the provided string is representing.
Definition akCore.cpp:389
tabLocation
Descirbes the tab location.
Definition akCore.h:202
@ tabLocationDown
Definition akCore.h:204
@ tabLocationLeft
Definition akCore.h:205
@ tabLocationRight
Definition akCore.h:206
@ tabLocationUp
Definition akCore.h:203
promptType
Describes the promt type.
Definition akCore.h:187
@ promptYesNoCancelIconLeft
Definition akCore.h:198
@ promptOkCancelIconLeft
Definition akCore.h:195
@ promptOk
Definition akCore.h:188
@ promptIconLeft
Definition akCore.h:194
@ promptIgnoreRetryCancel
Definition akCore.h:193
@ promptRetryCancel
Definition akCore.h:192
@ promptYesNo
Definition akCore.h:189
@ promptYesNoCancel
Definition akCore.h:190
@ promptOkIconLeft
Definition akCore.h:196
@ promptYesNoIconLeft
Definition akCore.h:197
@ promptOkCancel
Definition akCore.h:191
textAlignment
Describes the text alignment.
Definition akCore.h:210
@ alignLeft
Definition akCore.h:211
@ alignCenter
Definition akCore.h:213
@ alignRight
Definition akCore.h:212
UICORE_API_EXPORT QCryptographicHash::Algorithm toQCryptographicHashAlgorithm(HashAlgorithm _algorhitm)
Will return the QCryptographicHash::Algorithm corresponding to the provided HashAlgorithm.
Definition akCore.cpp:146
UICORE_API_EXPORT Qt::AlignmentFlag toQtAlignmentFlag(textAlignment _textAlignment)
Will return the corresponding Qt text alignment.
Definition akCore.cpp:374
commandType
Describes the type of an command.
Definition akCore.h:66
@ ctClearCreatedObjects
Definition akCore.h:67
HashAlgorithm
Definition akCore.h:121
@ hashSha1
Definition akCore.h:132
@ hashSha_384
Definition akCore.h:135
@ hashRealSha3_224
Definition akCore.h:128
@ hashRealSha3_512
Definition akCore.h:131
@ hashRealSha3_256
Definition akCore.h:129
@ hashKeccak_224
Definition akCore.h:122
@ hashMd4
Definition akCore.h:126
@ hashSha3_256
Definition akCore.h:137
@ hashSha512
Definition akCore.h:140
@ hashSha3_224
Definition akCore.h:136
@ hashSha_256
Definition akCore.h:134
@ hashMd5
Definition akCore.h:127
@ hashKeccak_256
Definition akCore.h:123
@ hashKeccak_512
Definition akCore.h:125
@ hashKeccak_384
Definition akCore.h:124
@ hashRealSha3_384
Definition akCore.h:130
@ hashSha_224
Definition akCore.h:133
@ hashSha3_384
Definition akCore.h:138
@ hashSha3_512
Definition akCore.h:139
eventType
Describes the type of an event.
Definition akCore.h:86
@ etItemTextChanged
Definition akCore.h:103
@ etChanged
Definition akCore.h:89
@ etItemChanged
Definition akCore.h:102
@ etEditingFinished
Definition akCore.h:116
@ etDoubleClicked
Definition akCore.h:96
@ etTimeout
Definition akCore.h:111
@ etTabToolbarClicked
Definition akCore.h:110
@ etSelectionChanged
Definition akCore.h:107
@ etKeyPressed
Definition akCore.h:104
@ etKeyReleased
Definition akCore.h:105
@ etExpanded
Definition akCore.h:97
@ etCursorPosotionChanged
Definition akCore.h:94
@ etReturnPressed
Definition akCore.h:115
@ etCollpased
Definition akCore.h:93
@ etDestroyed
Definition akCore.h:95
@ etClicked
Definition akCore.h:91
@ etCleared
Definition akCore.h:90
@ etInvalidEntry
Definition akCore.h:100
@ etDeleted
Definition akCore.h:117
@ etFocused
Definition akCore.h:98
@ etFocusLeft
Definition akCore.h:99
@ etLocationChanged
Definition akCore.h:106
@ etToggeledChecked
Definition akCore.h:112
@ etVisibilityChanged
Definition akCore.h:114
@ etIndexChanged
Definition akCore.h:101
@ etStateChanged
Definition akCore.h:108
@ etToggeledUnchecked
Definition akCore.h:113
@ etTabToolbarChanged
Definition akCore.h:109
@ etUnknownEvent
Definition akCore.h:87
@ etActivated
Definition akCore.h:88
@ etClosing
Definition akCore.h:92
bool flagIsSet(colorAreaFlag _flags, colorAreaFlag _testFlag)
Definition akCore.h:254
UICORE_API_EXPORT QString hashString(const QString &_str, HashAlgorithm _algorhitm)
Will return a hashed string that was hashed by the specified algorhitm.
Definition akCore.cpp:174
dockLocation
Describes the dock location of a dock widget.
Definition akCore.h:79
@ dockRight
Definition akCore.h:81
@ dockBottom
Definition akCore.h:82
@ dockLeft
Definition akCore.h:80
UICORE_API_EXPORT bool isDecimal(const char *str)
Returns true if the provided C-String is in a format ready to be converted to a double or float.
Definition akCore.cpp:87
UICORE_API_EXPORT timeFormat toTimeFormat(const QString &_str)
Will return the time format that the provided string is representing.
Definition akCore.cpp:397
keyType
Definition akCore.h:143
@ keyF2
Definition akCore.h:154
@ keyF12
Definition akCore.h:153
@ keyF7
Definition akCore.h:159
@ keyEscape
Definition akCore.h:149
@ keyF10
Definition akCore.h:151
@ keyAlt
Definition akCore.h:145
@ keyF5
Definition akCore.h:157
@ keyF1
Definition akCore.h:150
@ keyF11
Definition akCore.h:152
@ keyF9
Definition akCore.h:161
@ keyF4
Definition akCore.h:156
@ keyAltGr
Definition akCore.h:146
@ keyReturn
Definition akCore.h:162
@ keyControl
Definition akCore.h:147
@ keySpace
Definition akCore.h:163
@ keyF8
Definition akCore.h:160
@ keyF6
Definition akCore.h:158
@ keyUnknown
Definition akCore.h:144
@ keyF3
Definition akCore.h:155
@ keyDelete
Definition akCore.h:148
dateFormat
Describes the date format.
Definition akCore.h:71
@ dfDDMMYYYY
Definition akCore.h:72
@ dfYYYYDDMM
Definition akCore.h:75
@ dfYYYYMMDD
Definition akCore.h:74
@ dfMMDDYYYY
Definition akCore.h:73