/* SPDX-FileCopyrightText: 2020 Michail Vourlakos SPDX-License-Identifier: GPL-2.0-or-later */ // local #include "generictable.h" #include "activitydata.h" #include "appletdata.h" #include "errorinformationdata.h" #include "layoutdata.h" #include "screendata.h" #include "viewdata.h" // Qt #include namespace Latte { namespace Data { template GenericTable::GenericTable() { } template GenericTable::GenericTable(GenericTable &&o) : m_list(o.m_list) { } template GenericTable::GenericTable(const GenericTable &o) : m_list(o.m_list) { } //! Operators template GenericTable &GenericTable::operator=(const GenericTable &rhs) { m_list = rhs.m_list; return (*this); } template GenericTable &GenericTable::operator=(GenericTable &&rhs) { m_list = rhs.m_list; return (*this); } template GenericTable &GenericTable::operator<<(const T &rhs) { if (!rhs.id.isEmpty()) { m_list << rhs; } return (*this); } template GenericTable &GenericTable::operator<<(const GenericTable &rhs) { m_list << rhs.m_list; return (*this); } template GenericTable &GenericTable::insert(const int &pos, const T &rhs) { m_list.insert(pos, rhs); return (*this); } template GenericTable &GenericTable::insertBasedOnName(const T &rhs) { return insert(sortedPosForName(rhs.name), rhs); } template GenericTable &GenericTable::insertBasedOnId(const T &rhs) { return insert(sortedPosForId(rhs.id), rhs); } template bool GenericTable::operator==(const GenericTable &rhs) const { if (m_list.count() == 0 && rhs.m_list.count() == 0) { return true; } if (m_list.count() != rhs.m_list.count()) { return false; } for(int i=0; i bool GenericTable::operator!=(const GenericTable &rhs) const { return !(*this == rhs); } template T &GenericTable::operator[](const QString &id) { int pos{-1}; for(int i=0; i const T GenericTable::operator[](const QString &id) const { int pos{-1}; for(int i=0; i T &GenericTable::operator[](const uint &index) { return m_list[index]; } template const T GenericTable::operator[](const uint &index) const { return m_list[index]; } template GenericTable::operator QString() const { QString result; for(int i=0; i bool GenericTable::containsId(const QString &id) const { for(int i=0; i bool GenericTable::containsName(const QString &name) const { for(int i=0; i bool GenericTable::isEmpty() const { return m_list.count() <= 0; } template bool GenericTable::rowExists(const int &row) const { return (m_list.count()>=0 && row>=0 && row int GenericTable::indexOf(const QString &id) const { for(int i=0; i int GenericTable::rowCount() const { return m_list.count(); } template int GenericTable::sortedPosForId(const QString &id) const { int pos{0}; for(int i=0; i int GenericTable::sortedPosForName(const QString &name) const { int pos{0}; for(int i=0; i QString GenericTable::idForName(const QString &name) const { for(int i=0; i QStringList GenericTable::ids() const { QStringList idlist; for(int i=0; i QStringList GenericTable::names() const { QStringList nms; for(int i=0; i void GenericTable::clear() { m_list.clear(); } template void GenericTable::remove(const QString &id) { const int pos = indexOf(id); if (pos >= 0) { m_list.removeAt(pos); } } template void GenericTable::remove(const int &row) { if (rowExists(row)) { m_list.removeAt(row); } } //! Make linker happy and provide which table instances will be used. //! The alternative would be to move functions definitions in the header file //! but that would drop readability template class GenericTable; template class GenericTable; template class GenericTable; template class GenericTable; template class GenericTable; template class GenericTable; template class GenericTable; } }