File indexing completed on 2024-11-24 05:00:11
0001 /* 0002 SPDX-FileCopyrightText: 2015 Ivan Cukic <ivan.cukic(at)kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef RESOURCELINK_TABLE_H 0008 #define RESOURCELINK_TABLE_H 0009 0010 #include <QString> 0011 0012 #include "common.h" 0013 0014 namespace ResourceLink 0015 { 0016 struct Item { 0017 QString usedActivity; 0018 QString initiatingAgent; 0019 QString targettedResource; 0020 0021 inline std::tuple<const QString &, const QString &, const QString &> primaryKey() const 0022 { 0023 return std::tie(targettedResource, usedActivity, initiatingAgent); 0024 } 0025 }; 0026 0027 DECL_COLUMN(QString, usedActivity) 0028 DECL_COLUMN(QString, initiatingAgent) 0029 DECL_COLUMN(QString, targettedResource) 0030 0031 template<typename Range> 0032 inline std::vector<Item> groupByResource(const Range &range) 0033 { 0034 return groupBy(range, &Item::targettedResource, [](Item &acc, const Item &item) { 0035 acc.usedActivity += item.usedActivity + QLatin1Char(' '); 0036 acc.initiatingAgent += item.initiatingAgent + QLatin1Char(' '); 0037 }); 0038 } 0039 0040 } // namespace ResourceLink 0041 0042 #endif // RESOURCELINK_TABLE_H