11#include "calendarsupport_debug.h"
12#include <KLocalizedString>
14using namespace CalendarSupport;
16void CellItem::setSubCells(
int v)
21int CellItem::subCells()
const
26void CellItem::setSubCell(
int v)
31int CellItem::subCell()
const
36QString CellItem::label()
const
38 return xi18n(
"<placeholder>undefined</placeholder>");
41QList<CellItem *> CellItem::placeItem(
const QList<CellItem *> &cells, CellItem *placeItem)
44 QSet<int> subCellsInUse;
47 QList<CellItem *> overlappingItems{placeItem};
48 for (
int i = 0; i < overlappingItems.count(); i++) {
49 const auto checkItem = overlappingItems.at(i);
50 for (
const auto item : cells) {
51 if (item->overlaps(checkItem) && !overlappingItems.contains(item)) {
52 qCDebug(CALENDARSUPPORT_LOG) << item->label() <<
"overlaps" << checkItem->label();
53 overlappingItems.append(item);
54 if (item->subCell() >= maxSubCells) {
55 maxSubCells = item->subCells();
57 if (checkItem == placeItem) {
58 subCellsInUse.
insert(item->subCell());
64 if (overlappingItems.count() > 1) {
68 for (i = 0; i < maxSubCells; ++i) {
73 placeItem->setSubCell(i);
74 if (i == maxSubCells) {
76 for (
auto item : overlappingItems) {
77 item->setSubCells(maxSubCells);
80 placeItem->setSubCells(maxSubCells);
81 qCDebug(CALENDARSUPPORT_LOG) <<
"use subcell" << i <<
"of" << maxSubCells;
84 overlappingItems.clear();
85 placeItem->setSubCell(0);
86 placeItem->setSubCells(1);
89 return overlappingItems;
QString xi18n(const char *text, const TYPE &arg...)
bool contains(const QSet< T > &other) const const
iterator insert(const T &value)