File indexing completed on 2024-05-05 17:43:53

0001 /*
0002     SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "utils.h"
0008 
0009 int Utils::treeStructureToInt(int subscription, int section, int index)
0010 {
0011     return subscription * 1000000 + section * 1000 + index;
0012 }
0013 
0014 void Utils::intToTreeStructure(int source, int &subscription, int &section, int &index)
0015 {
0016     // TODO some better math :) or bit shifting or something
0017     index = source % 1000;
0018     section = (source / 1000) % 1000;
0019     subscription = source / 1000000;
0020 }
0021 
0022 QString Utils::itemActionName(const QVariantMap &item)
0023 {
0024     QString actionName = item.value(QStringLiteral("action")).toString();
0025     if (actionName.isEmpty()) {
0026         actionName = item.value(QStringLiteral("submenu-action")).toString();
0027     }
0028     return actionName;
0029 }