|
|
|
@ -26,17 +26,18 @@ namespace Latte {
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
|
|
LayoutsTable::LayoutsTable()
|
|
|
|
|
: GenericTable<Layout>()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayoutsTable::LayoutsTable(LayoutsTable &&o)
|
|
|
|
|
: m_layouts(o.m_layouts)
|
|
|
|
|
: GenericTable<Layout>(o)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayoutsTable::LayoutsTable(const LayoutsTable &o)
|
|
|
|
|
: m_layouts(o.m_layouts)
|
|
|
|
|
: GenericTable<Layout>(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<m_layouts.count(); ++i) {
|
|
|
|
|
QString id = m_layouts[i].id;
|
|
|
|
|
|
|
|
|
|
if (!rhs.containsId(id) || (*this)[id] != rhs[id]){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LayoutsTable::operator!=(const LayoutsTable &rhs) const
|
|
|
|
|
{
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Layout &LayoutsTable::operator[](const QString &id)
|
|
|
|
|
LayoutsTable LayoutsTable::subtracted(const LayoutsTable &rhs) const
|
|
|
|
|
{
|
|
|
|
|
int pos{-1};
|
|
|
|
|
LayoutsTable subtract;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].id == id){
|
|
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ((*this) == rhs) {
|
|
|
|
|
return subtract;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_layouts[pos];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Layout LayoutsTable::operator[](const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
int pos{-1};
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].id == id){
|
|
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
for(int i=0; i<m_list.count(); ++i) {
|
|
|
|
|
if (!rhs.containsId(m_list[i].id)) {
|
|
|
|
|
subtract << m_list[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_layouts[pos];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Layout &LayoutsTable::operator[](const uint &index)
|
|
|
|
|
{
|
|
|
|
|
return m_layouts[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Layout LayoutsTable::operator[](const uint &index) const
|
|
|
|
|
{
|
|
|
|
|
return m_layouts[index];
|
|
|
|
|
return subtract;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList LayoutsTable::allSharesIds() const
|
|
|
|
|
{
|
|
|
|
|
QStringList sharesIds;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].isShared()) {
|
|
|
|
|
for(int j=0; j<m_layouts[i].shares.count(); ++j) {
|
|
|
|
|
sharesIds << m_layouts[i].shares[j];
|
|
|
|
|
for(int i=0; i<m_list.count(); ++i) {
|
|
|
|
|
if (m_list[i].isShared()) {
|
|
|
|
|
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
|
|
|
sharesIds << m_list[i].shares[j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -147,12 +91,12 @@ QStringList LayoutsTable::allSharesNames() const
|
|
|
|
|
{
|
|
|
|
|
QStringList sharesNames;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].isShared()) {
|
|
|
|
|
for(int j=0; j<m_layouts[i].shares.count(); ++j) {
|
|
|
|
|
QString shareId = m_layouts[i].shares[j];
|
|
|
|
|
for(int i=0; i<m_list.count(); ++i) {
|
|
|
|
|
if (m_list[i].isShared()) {
|
|
|
|
|
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
|
|
|
QString shareId = m_list[i].shares[j];
|
|
|
|
|
int sid = indexOf(shareId);
|
|
|
|
|
sharesNames << m_layouts[sid].name;
|
|
|
|
|
sharesNames << m_list[sid].name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -160,119 +104,27 @@ QStringList LayoutsTable::allSharesNames() const
|
|
|
|
|
return sharesNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LayoutsTable LayoutsTable::subtracted(const LayoutsTable &rhs) const
|
|
|
|
|
{
|
|
|
|
|
LayoutsTable subtract;
|
|
|
|
|
|
|
|
|
|
if ((*this) == rhs) {
|
|
|
|
|
return subtract;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (!rhs.containsId(m_layouts[i].id)) {
|
|
|
|
|
subtract << m_layouts[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return subtract;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Latte::Layouts::SharesMap LayoutsTable::sharesMap() const
|
|
|
|
|
{
|
|
|
|
|
Latte::Layouts::SharesMap map;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].isShared()) {
|
|
|
|
|
for(int i=0; i<m_list.count(); ++i) {
|
|
|
|
|
if (m_list[i].isShared()) {
|
|
|
|
|
QStringList sharesNames;
|
|
|
|
|
|
|
|
|
|
for(int j=0; j<m_layouts[i].shares.count(); ++j) {
|
|
|
|
|
QString shareId = m_layouts[i].shares[j];
|
|
|
|
|
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
|
|
|
QString shareId = m_list[i].shares[j];
|
|
|
|
|
int sid = indexOf(shareId);
|
|
|
|
|
sharesNames << m_layouts[sid].name;
|
|
|
|
|
sharesNames << m_list[sid].name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
map[m_layouts[i].name] = sharesNames;
|
|
|
|
|
map[m_list[i].name] = sharesNames;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LayoutsTable::containsId(const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].id == id){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LayoutsTable::containsName(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].name == name){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LayoutsTable::rowExists(const int &row) const
|
|
|
|
|
{
|
|
|
|
|
return (m_layouts.count()>=0 && row>=0 && row<rowCount());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LayoutsTable::indexOf(const QString &id) const
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].id == id){
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LayoutsTable::rowCount() const
|
|
|
|
|
{
|
|
|
|
|
return m_layouts.count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString LayoutsTable::idForName(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
for(int i=0; i<m_layouts.count(); ++i) {
|
|
|
|
|
if (m_layouts[i].name == name) {
|
|
|
|
|
return m_layouts[i].id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LayoutsTable::clear()
|
|
|
|
|
{
|
|
|
|
|
m_layouts.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LayoutsTable::remove(const QString &id)
|
|
|
|
|
{
|
|
|
|
|
const int pos = indexOf(id);
|
|
|
|
|
|
|
|
|
|
if (pos >= 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<rowCount(); ++i) {
|
|
|
|
|
if (i == row) {
|
|
|
|
|
m_layouts[row].activities = QStringList(Data::Layout::FREEACTIVITIESID);
|
|
|
|
|
} else if (m_layouts[i].activities.contains(Data::Layout::FREEACTIVITIESID)) {
|
|
|
|
|
m_layouts[i].activities.removeAll(Data::Layout::FREEACTIVITIESID);
|
|
|
|
|
m_list[row].activities = QStringList(Data::Layout::FREEACTIVITIESID);
|
|
|
|
|
} else if (m_list[i].activities.contains(Data::Layout::FREEACTIVITIESID)) {
|
|
|
|
|
m_list[i].activities.removeAll(Data::Layout::FREEACTIVITIESID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|