File indexing completed on 2024-04-28 15:40:17
0001 /* SPDX-FileCopyrightText: 2014 Jesper K. Pedersen <blackie@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "SearchInfo.h" 0007 0008 namespace RemoteControl 0009 { 0010 0011 void RemoteControl::SearchInfo::addCategory(const QString &category) 0012 { 0013 m_categories.append(category); 0014 } 0015 0016 void SearchInfo::addValue(const QString &value) 0017 { 0018 m_values.append(value); 0019 } 0020 0021 void SearchInfo::pop() 0022 { 0023 m_categories.pop(); 0024 if (m_values.count() > m_categories.count()) 0025 m_values.pop(); 0026 } 0027 0028 void SearchInfo::clear() 0029 { 0030 m_categories.clear(); 0031 m_values.clear(); 0032 } 0033 0034 QString SearchInfo::currentCategory() const 0035 { 0036 if (m_categories.isEmpty()) 0037 return {}; 0038 return m_categories.top(); 0039 } 0040 0041 QDataStream &operator<<(QDataStream &stream, const SearchInfo &searchInfo) 0042 { 0043 stream << searchInfo.m_categories << searchInfo.m_values; 0044 return stream; 0045 } 0046 0047 QDataStream &operator>>(QDataStream &stream, SearchInfo &searchInfo) 0048 { 0049 stream >> searchInfo.m_categories >> searchInfo.m_values; 0050 return stream; 0051 } 0052 0053 QList<std::tuple<QString, QString>> RemoteControl::SearchInfo::values() const 0054 { 0055 QList<std::tuple<QString, QString>> result; 0056 for (int i = 0; i < m_values.count(); ++i) 0057 result.append(std::make_tuple(m_categories[i], m_values[i])); 0058 return result; 0059 } 0060 0061 } // namespace RemoteControl