diff --git a/app/data/generictable.cpp b/app/data/generictable.cpp index 3088e16a7..e5c049907 100644 --- a/app/data/generictable.cpp +++ b/app/data/generictable.cpp @@ -19,6 +19,7 @@ */ #include "generictable.h" +#include "layoutdata.h" #include @@ -140,24 +141,6 @@ const T GenericTable::operator[](const uint &index) const return m_list[index]; } -template -GenericTable GenericTable::subtracted(const GenericTable &rhs) const -{ - GenericTable subtract; - - if ((*this) == rhs) { - return subtract; - } - - for(int i=0; i bool GenericTable::containsId(const QString &id) const { @@ -242,5 +225,10 @@ void GenericTable::remove(const int &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; + } } diff --git a/app/data/generictable.h b/app/data/generictable.h index 7cebd4cd3..77033e0f0 100644 --- a/app/data/generictable.h +++ b/app/data/generictable.h @@ -50,8 +50,6 @@ public: T &operator[](const uint &index); const T operator[](const uint &index) const; - GenericTable subtracted(const GenericTable &rhs) const; - bool containsId(const QString &id) const; bool containsName(const QString &name) const; bool rowExists(const int &row) const; diff --git a/app/data/layoutstable.cpp b/app/data/layoutstable.cpp index 5d07d6fbc..d6df87c98 100644 --- a/app/data/layoutstable.cpp +++ b/app/data/layoutstable.cpp @@ -26,17 +26,18 @@ namespace Latte { namespace Data { LayoutsTable::LayoutsTable() + : GenericTable() { } LayoutsTable::LayoutsTable(LayoutsTable &&o) - : m_layouts(o.m_layouts) + : GenericTable(o) { } LayoutsTable::LayoutsTable(const LayoutsTable &o) - : m_layouts(o.m_layouts) + : GenericTable(o) { } @@ -44,98 +45,41 @@ LayoutsTable::LayoutsTable(const LayoutsTable &o) //! Operators LayoutsTable &LayoutsTable::operator=(const LayoutsTable &rhs) { - m_layouts = rhs.m_layouts; - + m_list = rhs.m_list; return (*this); } LayoutsTable &LayoutsTable::operator=(LayoutsTable &&rhs) { - m_layouts = rhs.m_layouts; - return (*this); -} - -LayoutsTable &LayoutsTable::operator<<(const Layout &rhs) -{ - if (!rhs.id.isEmpty()) { - m_layouts << rhs; - } - + m_list = rhs.m_list; return (*this); } -bool LayoutsTable::operator==(const LayoutsTable &rhs) const -{ - if (m_layouts.count() == 0 && rhs.m_layouts.count() == 0) { - return true; - } - - if (m_layouts.count() != rhs.m_layouts.count()) { - return false; - } - - for(int i=0; i=0 && row>=0 && row= 0) { - m_layouts.removeAt(pos); - } -} - -void LayoutsTable::remove(const int &row) -{ - if (rowExists(row)) { - m_layouts.removeAt(row); - } -} - void LayoutsTable::setLayoutForFreeActivities(const QString &id) { int row = indexOf(id); @@ -280,9 +132,9 @@ void LayoutsTable::setLayoutForFreeActivities(const QString &id) if (row>=0) { for(int i=0; i { public: @@ -42,38 +43,13 @@ public: //! Operators LayoutsTable &operator=(const LayoutsTable &rhs); LayoutsTable &operator=(LayoutsTable &&rhs); - LayoutsTable &operator<<(const Layout &rhs); - bool operator==(const LayoutsTable &rhs) const; - bool operator!=(const LayoutsTable &rhs) const; - Layout &operator[](const QString &id); - const Layout operator[](const QString &id) const; - Layout &operator[](const uint &index); - const Layout operator[](const uint &index) const; - LayoutsTable subtracted(const LayoutsTable &rhs) const; QStringList allSharesIds() const; QStringList allSharesNames() const; Latte::Layouts::SharesMap sharesMap() const; - bool containsId(const QString &id) const; - bool containsName(const QString &name) const; - bool rowExists(const int &row) const; - - int indexOf(const QString &id) const; - int rowCount() const; - - QString idForName(const QString &name) const; - - void clear(); - void remove(const int &row); - void remove(const QString &id); void setLayoutForFreeActivities(const QString &id); - -protected: - //! #id, layout_record - QList m_layouts; - }; }