summaryrefslogtreecommitdiffstats
path: root/kxkb/layoutunit.h
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2023-12-21 17:32:43 +0200
committerMavridis Philippe <[email protected]>2023-12-25 17:35:38 +0200
commit94cec968a8bdb4c51fe68c814b1d864fe887e65e (patch)
treec0b01bd3ea80f9484c8e1273f73e6ffb3b9830b7 /kxkb/layoutunit.h
parentc55cad68e9f36ddbf028f3bbf2674861057905a3 (diff)
downloadtdebase-94cec968a8bdb4c51fe68c814b1d864fe887e65e.tar.gz
tdebase-94cec968a8bdb4c51fe68c814b1d864fe887e65e.zip
Kxkb: move LayoutUnit struct into its own file and add getLayoutName function
Signed-off-by: Mavridis Philippe <[email protected]> (cherry picked from commit 9647d4c7ff182c1fadffb9c6218bc00132fe682e)
Diffstat (limited to 'kxkb/layoutunit.h')
-rw-r--r--kxkb/layoutunit.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/kxkb/layoutunit.h b/kxkb/layoutunit.h
new file mode 100644
index 000000000..f4d82f73f
--- /dev/null
+++ b/kxkb/layoutunit.h
@@ -0,0 +1,64 @@
+//
+//
+// Author: Andriy Rysin <[email protected]>, (C) 2006
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _LAYOUTUNIT_H
+#define _LAYOUTUNIT_H
+
+#include <tqstring.h>
+
+inline TQString createPair(TQString key, TQString value)
+{
+ if (value.isEmpty()) return key;
+ return TQString("%1(%2)").arg(key, value);
+}
+
+struct LayoutUnit {
+ TQString layout;
+ TQString variant;
+ TQString displayName;
+
+ LayoutUnit() {}
+
+ LayoutUnit(TQString layout_, TQString variant_):
+ layout(layout_),
+ variant(variant_)
+ {}
+
+ LayoutUnit(TQString pair) {
+ setFromPair( pair );
+ }
+
+ void setFromPair(const TQString& pair) {
+ layout = parseLayout(pair);
+ variant = parseVariant(pair);
+ }
+
+ TQString toPair() const {
+ return createPair(layout, variant);
+ }
+
+ bool operator<(const LayoutUnit& lu) const {
+ return layout<lu.layout ||
+ (layout==lu.layout && variant<lu.variant);
+ }
+
+ bool operator!=(const LayoutUnit& lu) const {
+ return layout!=lu.layout || variant!=lu.variant;
+ }
+
+ bool operator==(const LayoutUnit& lu) const {
+// kdDebug() << layout << "==" << lu.layout << "&&" << variant << "==" << lu.variant << endl;
+ return layout==lu.layout && variant==lu.variant;
+ }
+
+//private:
+ static const TQString parseLayout(const TQString &layvar);
+ static const TQString parseVariant(const TQString &layvar);
+};
+
+#endif // _LAYOUTUNIT_H \ No newline at end of file